package com.hotel.service.impl;  
  

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hotel.dao.mapper.UserMapper;
import com.hotel.entity.User;
import com.hotel.entity.UserExample;
import com.hotel.service.RegisterService;
import com.hotel.utils.Message;



  
@Service("registerService")  
public class RegisterServiceImpl implements RegisterService {  
	@Resource  
    private UserMapper userMapper;
	
	public String nameIsNotExist(User user) {
		UserExample example = new UserExample();
		UserExample.Criteria criteria = example.createCriteria();
		criteria.andAccountEqualTo(user.getAccount());
		List<User> list = userMapper.selectByExample(example);
		
		if(list.isEmpty()){
			return Message.Message_0000;
		}
		
		return Message.Message_1000;
	}

	public String putUser(User user){
		
		User record = new User();
		record.setId(null);
		record.setAccount(user.getAccount());
		record.setPassword(user.getPassword());
		record.setName(user.getName());
		record.setEmail(user.getEmail());
		record.setPhoneNumber(user.getPhoneNumber());
		record.setIdCard(user.getIdCard());
		record.setAvatar(user.getAvatar());
		if(1 == userMapper.insert(record)){
			return Message.Message_0001;
		}
		else{
			return Message.Message_1001;
		}
	}

	

 
}